package com.bluesmart.mia;

import bolts.Task;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.content.Context;
import android.content.Intent;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;

public class AddDeviceWifiActivity extends BaseActivity implements
		OnClickListener {

	WifiManager mainWifi;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_add_device_wifi);

		((TextView) findViewById(R.id.center))
				.setText(getString(R.string.wifi_title_2));

		findViewById(R.id.left).setOnClickListener(this);
		findViewById(R.id.btn).setOnClickListener(this);
	}

	@Override
	public void onClick(View arg0) {
		if (R.id.left == arg0.getId())
			finish();
		else if (R.id.btn == arg0.getId()) {
			// ?????wifi???Mia
			mainWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
			if (!mainWifi.isWifiEnabled()
					|| !mainWifi.getConnectionInfo().getSSID().contains("mia-")) {
				Toast.makeText(getApplicationContext(), "?????mia-xxx,wifi",
						Toast.LENGTH_LONG).show();		
				return;
			}
			startActivity(new Intent(this, AddDeviceInfoActivity.class));
			finish();
		}
	}
}
